package com.touchdrive;

final public class TouchPad {
	int XPos;
	int YPos;
	int deadZoneX=50;
	int deadZoneY=50;
	int invertX=1;
	int invertY=-1;
	int lowerX;
	int upperX;
	int lowerY;
	int upperY;
	int padSizeX=500;
	int padSizeY=700;
	boolean returnToZero=true;
	boolean useNetwork=false;
	
	void deadZone() {
		lowerX=(padSizeX-deadZoneX)/2;
		upperX=padSizeX-lowerX;
		lowerY=(padSizeY-deadZoneY)/2;
		upperY=padSizeY-lowerY;
		}
	
	void position(int mouseX, int mouseY, boolean touched) {
		if (touched){
		if (mouseX<lowerX) {
		      XPos=(int)((float)(mouseX-lowerX)/lowerX*255*invertX);
		    } else if (mouseX>upperX) {
		      XPos=(int)((float)(mouseX-upperX)/lowerX*255*invertX);
		    } else {
		      XPos=0;
		    }

		if (mouseY<lowerY) {
		      YPos=(int)((float)(mouseY-lowerY)/lowerY*255*invertY);
		    } else if (mouseY>upperY) {
		      YPos=(int)((float)(mouseY-upperY)/lowerY*255*invertY);
		    } else {
		      YPos=0;
		    }
		} else{
			YPos=0;
			XPos=0;
		}
	}
}
